<template>
  <div class="book-card">
    <van-checkbox v-model="isCheck" checked-color="#2c59b7"/>
    
    <img :src="`https://file.ituring.com.cn/SmallCover/${coverKey}`" alt="" />
    <div class="card-right">
      <p class="book-name">{{ name }}</p>
      <p class="book-type">电子书</p>
      <div class="summarize">
        <p class="book-price">{{ price }}元</p>
        <div class="book-count">
          <span class="minus" @click="tip()">-</span>
          
          <input type="number" v-model="buyNum" readonly="readonly"/>
          <span class="add" @click="tip()">+</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast } from 'vant';
export default {
  props: ["coverKey", "name", "type", "price", "quantity", "checked","id"],
  data() {
    return {
      //
      buyNum: this.quantity,
    };
  },
  computed: {
    // 
    isCheck: {
      get() {
        return this.checked;
      },
      set(v) {
        this.$emit('setChecked',this.id,v)
      },
    },
  },
  methods:{
    tip(){
      Toast('电子书不能修改数量')
    }
  }
};
</script>

<style lang="scss" scoped>
.book-card {
  display: flex;
  align-items: center;
  padding: 15px;
  .van-checkbox {
    width: 20px;
    height: 20px;
    margin-right: 20px;
  }
  img {
    width: 70px;
    height: 95px;
    margin-right: 15px;
  }
  .card-right {
    width: 220px;
    height: 100px;
    .book-name {
      color: var(--book-name-font-black);
      font-size: 14px;
      line-height: 19px;
    }
    .book-type {
      color: var(--more-font-grey);
      font-size: 14px;
      line-height: 23px;
      margin-top: 10px;
    }
    .summarize {
      margin-top: 5px;
      display: flex;
      justify-content: space-between;
      .book-price {
        color: var(--book-name-font-black);
        font-size: 14px;
        font-weight: bolder;
        line-height: 23px;
      }
      .book-count {
        display: flex;
        align-items: center;
        font-size: 18px;
        .minus,
        .add {
          display: inline-block;
          box-sizing: border-box;
          width: 20px;
          height: 22px;
          border: 1px solid #ccc;
          color: #ccc;
          padding: 0px 4px;
          text-align: center;
          line-height: 22px;
        }
        input {
          display: inline-block;
          box-sizing: border-box;
          outline: none;
          border: none;
          border: 1px solid #ccc;
          width: 38px;
          height: 22px;
          margin: 0 5px;
          text-align: center;
          font-size: 14px;
          color: var(--book-name-font-black);
        }
      }
    }
  }
}
</style>
